package com.feiyu.simplesort;

import java.util.Random;

/**
 * @Author nanshouxiao@teacher.com.cn
 * @Date 2017-10-26 17:01
 */
public class MainTest {
    public static int[] getRandomArray(int cap) {
        int[] array = new int[cap];
        Random random = new Random(10L);
        for (int i = 0; i < cap; i++) {
            array[i] = random.nextInt(100);
        }
        return array;
        // 13,80,93,90,46,56,97,88,81,14
    }

    public static void main(String[] args) {
        BaseSort sort = new MergeSort();
        testResult(sort);
        testTime(sort);
//        testTime(new SelectSort());
//        testTime(new BubbleSort());

    }

    private static void testResult(BaseSort sort) {
        int[] array = getRandomArray(10);
        for (int n : array) {
            System.out.print(n);
            System.out.print(",");
        }
        sort.sort(array);
        System.out.println();
        for (int n : array) {
            System.out.print(n);
            System.out.print(",");
        }
        System.out.println();
    }
    private static void testTime(BaseSort sort) {
        int[] array = getRandomArray(1000000);
        long time = System.currentTimeMillis();
        sort.sort(array);
        System.out.println(sort.getClass().getSimpleName() + " 使用时间");
        System.out.println(System.currentTimeMillis() - time);
    }
}
